function S = padsum(A,B)
[M1,N1] = size(A);
[M2,N2] = size(B);
MS = max(M1,M2);
NS = max(N1,N2);
S = zeros(MS,NS);
S(1:M1,1:N1) = A;
S(1:M2,1:N2) = S(1:M2,1:N2) + B;

end